package com.caiden_micheal.menu.mapper;

import com.caiden_micheal.menu.domain.Icon;
import com.caiden_micheal.menu.domain.Menu;
import com.caiden_micheal.menu.dto.IconPageQueryDTO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MenuMapper {

    List<Menu> findByParentId(@Param("parentMenuId") Long parentMenuId, @Param("status") Integer status);

    @Select("SELECT * FROM sys_menu WHERE id=#{id}")
    Menu findById(@Param("id") Long id);

    void update(@Param("menu") Menu menu);

    @Select("SELECT * FROM sys_icon ORDER BY `index` desc")
    List<Icon> findIcon();

    void addMenu(@Param("menu") Menu menu);

    @Select("SELECT * FROM sys_menu WHERE authority_id=#{authorityId}")
    Menu findByPermissionId(@Param("authorityId") Long id);

    @Delete("DELETE FROM sys_menu WHERE id=#{id}")
    void removeById(@Param("id") Long id);

    @Select("SELECT * from sys_icon WHERE name=#{name}")
    Icon findIconByName(String name);

    void addIcon(Icon icon);

    void editIcon(Icon icon);

    List<Icon> findIconPageQueryByCondition(IconPageQueryDTO iconPageQueryDTO);

    Integer findIconPageQueryByConditionCount(IconPageQueryDTO iconPageQueryDTO);
}
